package com.smedi.ismedi.authoritymanagement.api.feign;

import com.smedi.ismedi.authority.starter.response.AuthorityAccessResponse;
import com.smedi.ismedi.authoritymanagement.api.dto.request.DataPermissionScopeRequest;
import com.smedi.ismedi.authoritymanagement.api.dto.response.WebClientStructureResponse;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.hibernate.validator.constraints.Length;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Api(tags = {"身份证认证接口"})
@FeignClient(name = "ismedi-authority-management")
@RequestMapping(value = "/api/v1/authority/access")
public interface RemoteAuthorityAccessFeignApi {
    /**
     * 校验令牌获取用户信息
     *
     * @param token
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "校验令牌获取用户信息")
    @GetMapping(value = "/validateTokenAndGetAuthorityAccessAndRefreshExpress")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "token", value = "令牌", dataType = "String", dataTypeClass = String.class),
    })
    ResponseData<AuthorityAccessResponse> getValidateTokenAndGetAuthorityAccessAndRefreshExpress(@Validated @RequestParam("token") @Length(min = 19, max = 19) String token);

    /**
     * 将用户选择的三级组织数据权限绑定在令牌上
     *
     * @param dataPermissionScopeRequest
     * @return
     */
    @ApiOperation(httpMethod = "PUT", value = "将用户选择的三级组织数据权限绑定在令牌上")
    @PutMapping(value = "/boundDataPermissionScope")
    ResponseData<Boolean> putBoundDataPermissionScope(@RequestBody DataPermissionScopeRequest dataPermissionScopeRequest);

    /**
     * 根据用户获取有权限的菜单和路由
     *
     * @param rootCode
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "根据用户获取有权限的菜单和路由")
    @GetMapping(value = "/getMenuInfrastructure")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "rootCode", value = "根节点编码", dataType = "String", dataTypeClass = String.class)})
    ResponseData<WebClientStructureResponse> getMenuInfrastructure(@RequestParam("rootCode") String rootCode);

    /**
     * 根据token获取用户信息
     *
     * @return ResponseData<AuthorityAccessResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "获取当前用户信息")
    @GetMapping(value = "/current-user/info")
    ResponseData<AuthorityAccessResponse> getCurrentUserInfo();
}
